Transactions Property Example

This example demonstrates the Transactions property in Microsoft Jet and ODBCDirect workspaces.

Sub TransactionsX()

    Dim wrkJet As Workspace
    Dim wrkODBC As Workspace
    Dim dbsNorthwind As Database
    Dim conPubs As Connection
    Dim rstTemp As Recordset

    ' Open Microsoft Jet and ODBCDirect workspaces, a Microsoft
    ' Jet database, and an ODBCDirect connection.
    Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
    Set wrkODBC = CreateWorkspace("", "admin", "", dbUseODBC)
    Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb")
    Set conPubs = wrkODBC.OpenConnection("", , , _
        "ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")

    ' Open two different Recordset objects and display the
    ' Transactions property of each.

    Debug.Print "Opening Microsoft Jet table-type " & _
        "recordset..."
    Set rstTemp = dbsNorthwind.OpenRecordset( _
        "Employees", dbOpenTable)
    Debug.Print "  Transactions = " & rstTemp.Transactions

    Debug.Print "Opening forward-only-type " & _
        "recordset where the source is an SQL statement..."
    Set rstTemp = dbsNorthwind.OpenRecordset( _
        "SELECT * FROM Employees", dbOpenForwardOnly)
    Debug.Print "  Transactions = " & rstTemp.Transactions

    ' Display Transactions property of a Connection object in 
    ' an ODBCDirect workspace.
    Debug.Print "Testing Transaction property of " & _
        "an ODBC connection..."
    Debug.Print "  Transactions = " & conPubs.Transactions

    rstTemp.Close
    dbsNorthwind.Close
    conPubs.Close
    wrkJet.Close
    wrkODBC.Close

End Sub